package com.exam.api.modules.system.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Map;

/**
 * 权限菜单表实体
 *
 * @author bcheng
 */
@Schema(description = "权限菜单表")
@Data
@TableName(value = "tbl_menu")
public class TblMenu implements Serializable {
    /**
     * 菜单ID
     */
    @TableId(value = "menu_id", type = IdType.ASSIGN_ID)
    @Schema(description = "菜单ID")
    @NotNull(message = "菜单ID不能为null")
    private Long menuId;

    /**
     * 父ID
     */
    @TableField(value = "parent_menu_id")
    @Schema(description = "父ID")
    @NotNull(message = "父ID不能为null")
    private Long parentMenuId;

    /**
     * 平台 WEB APP H5
     */
    @TableField(value = "platform")
    @Schema(description = "平台 WEB APP H5")
    @Size(max = 10, message = "平台最大长度要小于 64")
    @NotBlank(message = "平台不能为空")
    private String platform;

    /**
     * 菜单名称
     */
    @TableField(value = "`name`")
    @Schema(description = "菜单名称")
    @Size(max = 64, message = "菜单名称最大长度要小于 64")
    @NotBlank(message = "菜单名称不能为空")
    private String name;

    /**
     * 唯一编码
     */
    @TableField(value = "code")
    @Schema(description = "唯一编码")
    @Size(max = 64, message = "唯一编码最大长度要小于 64")
    @NotBlank(message = "唯一编码不能为空")
    private String code;

    /**
     * 菜单类型
     */
    @TableField(value = "`type`")
    @Schema(description = "菜单类型")
    private Integer type;

    /**
     * 排序
     */
    @TableField(value = "sort")
    @Schema(description = "排序")
    private Long sort;

    /**
     * 路由地址
     */
    @TableField(value = "`path`")
    @Schema(description = "路由地址")
    @Size(max = 100, message = "路由地址最大长度要小于 100")
    private String path;

    /**
     * 组件地址
     */
    @TableField(value = "component")
    @Schema(description = "组件地址")
    @Size(max = 100, message = "组件地址最大长度要小于 100")
    private String component;

    /**
     * 菜单图标
     */
    @TableField(value = "icon")
    @Schema(description = "菜单图标")
    @Size(max = 64, message = "菜单图标最大长度要小于 64")
    private String icon;

    /**
     * 是否显示
     */
    @TableField(value = "is_show")
    @Schema(description = "是否显示")
    private Boolean isShow;

    /**
     * 是否链接
     */
    @TableField(value = "is_link")
    @Schema(description = "是否链接")
    private Boolean isLink;

    /**
     * 外部链接地址
     */
    @TableField(value = "url")
    @Schema(description = "外部链接地址")
    @Size(max = 255, message = "外部链接地址最大长度要小于 255")
    private String url;

    /**
     * 是否启用
     */
    @TableField(value = "enabled")
    @Schema(description = "是否启用")
    private Boolean enabled;

    /**
     * 拓展参数
     */
    @TableField(value = "extra", typeHandler = JacksonTypeHandler.class)
    @Schema(description = "拓展参数")
    private Map<String, Object> extra;

    /**
     * 是否删除
     */
    @TableField(value = "is_delete")
    @Schema(description = "是否删除")
    @TableLogic
    private Integer isDelete;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    /**
     * 创建用户
     */
    @TableField(value = "create_user")
    @Schema(description = "创建用户")
    private Long createUser;

    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    /**
     * 更新用户
     */
    @TableField(value = "update_user")
    @Schema(description = "更新用户")
    private Long updateUser;

    @Serial
    private static final long serialVersionUID = 1L;
}
